﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ESHOP.DAO;
using ESHOP.UTIL;
using ESHOP.Domain;
using E_Shop.Common;

namespace E_Shop
{
    public partial class CompanyManageSellLead : Authentication
    {
        SellLeadDao _sellDao = new SellLeadDao();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {

            var sellList = _sellDao.GetAllSellByCompanyId(Acount.MACT);
            gvSell.DataSource = sellList;
            gvSell.DataBind();
            lbnumber.Text = sellList.Count().ToString();
            UpGrid.Update();

        }

        protected void gvSell_RowCommand(object seder, GridViewCommandEventArgs e)
        {
            var buyId = e.CommandArgument.ToString();
            var objectBuy = _sellDao.Get(buyId);
            var idname = e.CommandName;
            switch (idname)
            {
                case "deleteSell":
                    {
                        _sellDao.Delele(objectBuy.ID);
                        LoadData();
                        UpGrid.Update();
                        break;
                    }
                case "detailSell":
                    {
                        Response.Redirect("CompanyBuyingDetail?&id", true);
                        break;
                    }
                

            }
        }   

    }
}